var timeOpForm = document.getElementsByName("timeOpForm")[0];
var timezoneOffsetSpan = document.getElementById("timezone-offset-span");

function time2Number() {
    var timeString = timeOpForm.timeString.value;
    if(timeString) {
        timeOpForm.timeNumber.value = moment(timeString).valueOf()
    }
}

function time2String() {
    var timeNumber = timeOpForm.timeNumber.value;
    if(timeNumber) {
        timeNumber = parseInt(timeNumber);
        timeOpForm.timeString.value = moment(timeNumber).format("YYYY-MM-DD HH:mm:ss");
    }
}

function timeClear() {
    timeOpForm.timeNumber.value = "";
    timeOpForm.timeString.value = "";
}

function timeGet() {
    timeOpForm.timeNumber.value = moment().valueOf();
    timeOpForm.timeString.value = moment().format("YYYY-MM-DD HH:mm:ss");
}

var timezoneOffset = new Date().getTimezoneOffset() / 60;
var timezoneOffsetDisp = "UTC";
if(timezoneOffset < 0) {
    timezoneOffsetDisp += ("+" + -timezoneOffset);
} else if (timezoneOffset > 0) {
    timezoneOffsetDisp += ("-" + timezoneOffset);
}

timezoneOffsetSpan.innerHTML = timezoneOffsetDisp;